package RPS;

import java.util.ArrayList;

import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import RPS.RPSEnum;

public class TestRockPapersScissors 
{
	RockPapersScissors rps;
	ArrayList arr1 = new ArrayList<RPSEnum>();
	ArrayList arr2 = new ArrayList<RPSEnum>();
	Player ply1;
	Player ply2;
	
	public TestRockPapersScissors()
	{
		
	}
	
	@BeforeClass
	void setUpClass()
	{
		this.rps = new RockPapersScissors();
		this.ply1 = new Player("Player1", arr1);
		this.ply2 = new Player("Player2", arr2);
		this.ply1.contructList(2);
		this.ply2.contructList(3);
	}
	
	@AfterClass
	void tearDownClass()
	{
		this.rps = null;
	}
	
	@Test
	void testWinPlay(String p1, String p2)
	{
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)), Result.WIN);
		Assert.assertEquals(rps.play(ply1, ply2), Result.WIN);
	}
	
	@Test
	void testTiePlay(String p1, String p2)
	{
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)), Result.TIE);
		Assert.assertEquals(rps.play(ply1, ply2), Result.TIE);
		
	}
	
	@Test
	void testLostPlay(String p1, String p2)
	{
		Assert.assertEquals(rps.play(RPSEnum.valueOf(p1), RPSEnum.valueOf(p2)), Result.LOST);
		Assert.assertEquals(rps.play(ply1, ply2), Result.LOST);
	}
	
	@DataProvider(name = "won")
	public Object[][] createWonData()
	{
		return new Object[][]
		{
			{"ROCK", "SCISSORS"},
			{"PAPERS", "ROCK"},
			{"SCISSORS", "PAPERS"},
		};
	}
	
	@DataProvider(name = "tied")
	public Object[][] createTiedData()
	{
		return new Object[][]
		{
			{"ROCK", "ROCK"},
			{"PAPERS", "PAPERS"},
			{"SCISSORS", "SCISSORS"},
		};
	}
	
	@DataProvider(name = "failed")
	public Object[][] createFailedData()
	{
		return new Object[][]
		{
			{"ROCK", "PAPERS"},
			{"PAPERS", "SCISSORS"},
			{"SCISSORS", "ROCK"},
		};
	}
}
